﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StudentManageWinForm
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
            staLbVersion.Text = "软件版本" + Application.ProductVersion;
            staLbCurrentUser.Text = Program.CurrentUser.UserName;
        }
        #region 子窗体
        private FrmLogin _frmLogin = null;
        private FrmUserManage _frmUserManage = null;
        private FrmAddStudent _frmAddStudent = null;
        private FrmStudentManage _frmStudentManage = null;
        private FrmScoreManage _frmScoreManage = null;
        private FrmScoreQuickSearch _frmScoreQuickSearch = null;
        #endregion
        public void FormShow<T>(ref T obj)where T:Form,new()
        {
            if (obj==null||obj.IsDisposed)
            {
                obj = new T();
                obj.Show();
            }
            else
            {
                obj.Activate();
                obj.WindowState = FormWindowState.Normal;
            }
        }
        #region UI交互
        private void 退出EToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void 修改密码MToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormShow(ref _frmUserManage);
        }

        private void 添加学员RToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormShow(ref _frmAddStudent);
        }

        private void 学员信息管理DToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormShow(ref _frmStudentManage);
        }

        private void 成绩查询与分析YToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormShow(ref _frmScoreManage);
        }

        private void 成绩快速查询GToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormShow(ref _frmScoreQuickSearch);
        }
        #endregion

    }
}
